import { getRequest, postRequest, putRequest, deleteRequest } from '/@/lib/axios';

/**
 * 工作流相关的 API 接口集合
 */

/**
 * 流程相关的 API 接口
 */
export const processApi = {
  // 获取流程列表
  listProcess: (query) => getRequest('/workflow/process/list', query),
  // 获取流程表单数据
  getProcessForm: (query) => getRequest('/workflow/process/getProcessForm', query),
  // 启动流程实例
  startProcess: (processDefId, data) => postRequest('/workflow/process/start/' + processDefId, data),
  // 删除流程实例
  delProcess: (ids) => deleteRequest('/workflow/process/instance/' + ids),
  // 获取流程的 BPMN XML
  getBpmnXml: (processDefId) => getRequest('/workflow/process/bpmnXml/' + processDefId),
  // 获取流程详情
  detailProcess: (query) => getRequest('/workflow/process/detail', query),
  // 获取我发起的流程列表
  listOwnProcess: (query) => getRequest('/workflow/process/ownList', query),
  // 获取待办流程列表
  listTodoProcess: (query) => getRequest('/workflow/process/todoList', query),
  // 获取待签收的流程列表
  listClaimProcess: (query) => getRequest('/workflow/process/claimList', query),
  // 获取已完成的流程列表
  listFinishedProcess: (query) => getRequest('/workflow/process/finishedList', query),
  // 获取抄送的流程列表
  listCopyProcess: (query) => getRequest('/workflow/process/copyList', query),
  // 终止流程
  stopProcess: (data) => postRequest('/workflow/task/stopProcess', data),
};

/**
 * 任务相关的 API 接口
 */
export const taskApi = {
  // 完成任务
  complete: (data) => postRequest('/workflow/task/complete', data),
  // 委派任务
  delegate: (data) => postRequest('/workflow/task/delegate', data),
  // 转交任务
  transfer: (data) => postRequest('/workflow/task/transfer', data),
  // 加签任务
  addSign: (data) => postRequest('/workflow/task/addSign', data),
  // 退回任务
  returnTask: (data) => postRequest('/workflow/task/return', data),
  // 驳回任务
  rejectTask: (data) => postRequest('/workflow/task/reject', data),

  claimTask: (data) => postRequest('/workflow/task/claim', data),

  returnList: (data) => postRequest('/workflow/task/returnList', data),

  returnTaskList: (data) => postRequest('/workflow/task/returnTaskList', data),

  revokeProcess: (data) => postRequest('/workflow/task/revokeProcess', data),
};
